package com.newbingo.dto;

import java.util.ArrayList;
import java.util.List;


import com.newbingo.dao.imple.IGameRebateDao;
import com.newbingo.dto.imple.IGameRebateDto;

import com.newbingo.entity.GameRebate;
import com.newbingo.util.Pager;

public class GameRebateDto implements IGameRebateDto {

	private Integer id;
	private Integer agentId;
	private Integer gameno;
	private String gameName;
	private Integer amount;
	private Integer rebate;
	private String startTime;
	private String endTime;

	private IGameRebateDao gameRebateDao = null;

	/*
	 * 分页查询(non-Javadoc)
	 * @see com.newbingo.dto.imple.IGameRebateDto#findRebate(int, int, java.lang.Integer, java.lang.String)
	 */
	public Pager findRebate(int start, int limit, Integer agentId,
			String gameName) {
		Pager pager = gameRebateDao.findRebate(start, limit, agentId, gameName);
		List<GameRebate> list = pager.getData();
		Pager page = new Pager();
		List<GameRebateDto> listDto = new ArrayList<GameRebateDto>();
		GameRebateDto rebate = null;
		for (GameRebate gameRebate : list) {
			rebate = new GameRebateDto();
			rebate.setId(gameRebate.getId());
			rebate.setAgentId(gameRebate.getAgent().getUno());
			rebate.setGameno(gameRebate.getGame().getGameno());
			rebate.setGameName(gameRebate.getGame().getGamename());
			rebate.setAmount(gameRebate.getAmount());
			rebate.setRebate(gameRebate.getRebate());
			rebate.setStartTime(gameRebate.getStartTime() + "");
			rebate.setEndTime(gameRebate.getEndTime() + "");
			listDto.add(rebate);
		}
		page.setData(listDto);
		return page;
	}
	
	/*
	 * 根据ID 查询 返回DTO对象(non-Javadoc)
	 * @see com.newbingo.dto.imple.IGameRebateDto#findById(java.lang.Integer)
	 */
	public GameRebateDto findById(Integer Id) {
        GameRebate gameRebate=gameRebateDao.findById(Id);
        GameRebateDto rebate=new GameRebateDto();
		rebate.setId(gameRebate.getId());
		rebate.setAgentId(gameRebate.getAgent().getUno());
		rebate.setGameno(gameRebate.getGame().getGameno());
		rebate.setGameName(gameRebate.getGame().getGamename());
		rebate.setAmount(gameRebate.getAmount());
		rebate.setRebate(gameRebate.getRebate());
		rebate.setStartTime(gameRebate.getStartTime() + "");
		rebate.setEndTime(gameRebate.getEndTime() + "");
        return rebate;
	}

	public IGameRebateDao getGameRebateDao() {
		return gameRebateDao;
	}

	public void setGameRebateDao(IGameRebateDao gameRebateDao) {
		this.gameRebateDao = gameRebateDao;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getAgentId() {
		return agentId;
	}

	public void setAgentId(Integer agentId) {
		this.agentId = agentId;
	}

	public Integer getGameno() {
		return gameno;
	}

	public void setGameno(Integer gameno) {
		this.gameno = gameno;
	}

	public String getGameName() {
		return gameName;
	}

	public void setGameName(String gameName) {
		this.gameName = gameName;
	}

	public Integer getAmount() {
		return amount;
	}

	public void setAmount(Integer amount) {
		this.amount = amount;
	}

	public Integer getRebate() {
		return rebate;
	}

	public void setRebate(Integer rebate) {
		this.rebate = rebate;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}


}
